home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume10 / ifp / part02 < prev    next >
Encoding:
Internet Message Format  |  1987-07-05  |  59.3 KB

  1. Path: uunet!rs
  2. From: rs@uunet.UU.NET (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v10i035: Interpreted Functional Programming lanuage, Part 02/07
  5. Message-ID: <572@uunet.UU.NET>
  6. Date: 7 Jul 87 04:32:09 GMT
  7. Organization: UUNET Communications Services, Arlington, VA
  8. Lines: 2192
  9. Approved: rs@uunet.uu.net
  10.  
  11. Mod.sources: Volume 10, Number 35
  12. Submitted by: robison@b.cs.uiuc.edu (Arch Robison)
  13. Archive-name: ifp/Part02
  14.  
  15. #! /bin/sh
  16. # This is a shell archive, meaning:
  17. # 1. Remove everything above the #! /bin/sh line.
  18. # 2. Save the resulting text in a file.
  19. # 3. Execute the file with /bin/sh.
  20. # The following files will be created:
  21. #    manual
  22. export PATH; PATH=/bin:$PATH
  23. if test -f 'manual'
  24. then
  25.     echo shar: over-writing existing file "'manual'"
  26. fi
  27. cat << \SHAR_EOF > 'manual'
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.           Professional Workstation
  48.          Research Group Technical Report #7
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.          Illinois FP User's Manual
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.               Arch D. Robison
  64.            Department of Computer Science
  65.      University of Illinois at Urbana-Champaign
  66.            Urbana, Illinois 61801
  67.  
  68.               February 9, 1987
  69.  
  70.  
  71.  
  72.              _T_a_b_l_e _o_f _C_o_n_t_e_n_t_s
  73.  
  74. 1.  Overview ..........................................    1
  75. 2.  Prerequisites .....................................    2
  76. 2.1.  Organization ....................................    2
  77. 2.2.  Environment (UNIX) ..............................    3
  78. 2.3.  Environment (MSDOS) .............................    3
  79. 3.  Using IFP .........................................    4
  80. 3.1.  Starting IFP ....................................    4
  81. 3.2.  Creating and Editing Definitions ................    4
  82. 3.3.  Applying Functions ..............................    5
  83. 3.4.  Executing UNIX Commands .........................    5
  84. 3.5.  Executing MSDOS Commands ........................    6
  85. 4.  Language ..........................................    6
  86. 4.1.  Objects .........................................    6
  87. 4.2.  Functions .......................................    7
  88. 4.2.1.  Primitive Functions ...........................    9
  89. 4.2.1.1.  Structural Functions (/sys) .................   11
  90. 4.2.1.2.  Arithmetic (/math/arith) ....................   12
  91. 4.2.1.3.  Logic (/math/logic) .........................   14
  92. 4.2.1.4.  String Functions (/sys) .....................   16
  93. 4.2.1.5.  Miscellaneous Functions (/sys) ..............   16
  94. 4.2.2.  User Defined Functions ........................   19
  95. 4.2.3.  Functional Variables ..........................   20
  96. 4.3.  Functional Forms ................................   21
  97. 4.3.1.  Constant ......................................   21
  98. 4.3.2.  Selection .....................................   22
  99. 4.3.3.  Composition ...................................   22
  100. 4.3.4.  Construction ..................................   23
  101. 4.3.5.  Apply to Each .................................   23
  102. 4.3.6.  If-Then-Else ..................................   24
  103. 4.3.7.  Filter ........................................   24
  104. 4.3.8.  Right Insert ..................................   25
  105. 4.3.9.  While .........................................   26
  106. 4.3.10.  Fetch[8] .....................................   26
  107. 4.4.  Comments ........................................   27
  108. 4.5.  Syntax Summary ..................................   27
  109. 5.  IFP Graphics (optional)[9] ........................   27
  110. 5.1.  Coordinate System ...............................   28
  111. 5.2.  Display List Structure ..........................   28
  112. 5.2.1.  Polyline ......................................   28
  113. 5.2.2.  Color .........................................   29
  114. 5.2.3.  Transform .....................................   29
  115. 5.2.4.  Text ..........................................   29
  116. 6.  Debugging .........................................   30
  117. 7.  Differences between IFP and Backus' FP ............   31
  118. 7.1.  Domain ..........................................   31
  119. 7.2.  Functions .......................................   31
  120. 7.3.  Functional Forms ................................   31
  121. 7.4.  Syntax ..........................................   32
  122. 8.  Functional Programming Techniques .................   33
  123. 8.1.  Functional Programming Identities ...............   33
  124. 8.2.  Common Subfunctions .............................   34
  125. 8.3.  State Machines ..................................   34
  126. 8.4.  Tail Recursion ..................................   35
  127. 9.  Installation Notes ................................   35
  128. 9.1.  Machine Dependence ..............................   35
  129. 9.2.  Compiling Options ...............................   36
  130.  
  131.  
  132.                  i
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.           _I_l_l_i_n_o_i_s _F_P _0._5 _U_s_e_r_s _M_a_n_u_a_l[_1]
  141.  
  142.  
  143.  
  144. _1.  _O_v_e_r_v_i_e_w
  145.  
  146.  
  147.      Functional Programming (FP) [Bac78a] is a radically new
  148.  
  149. form  of  programming.  FP programs have neither the control
  150.  
  151. flow nor variables of Von-Neumann languages.   Instead  pro-
  152.  
  153. grams  are  directly constructed from smaller programs. As a
  154.  
  155. result, FP offers a new style of programming  with  numerous
  156.  
  157. advantages, including:
  158.  
  159.  
  160.             Modular Programming
  161.             Program Verification
  162.             Parallel Processing
  163.             Optimization
  164.  
  165.  
  166.  
  167.      IFP (Illinois Functional  Programming)  [Rob87a,Rob87b]
  168.  
  169. is  an interactive functional programming implementation for
  170.  
  171. UNIX and MSDOS systems.  The user may  interactively  create
  172.  
  173. and execute functional programs.  In addition to Backus' FP,
  174.  
  175. IFP has the following features:
  176.  
  177.  
  178.        Hierarchical and Modular Function Organization
  179.        Block-Structured Syntax
  180.        Error Explanations
  181.        Graphics Display List Processor[2]
  182.  
  183.  
  184. The interpreter is an order of magnitude  more  compact  and
  185. ____________________
  186.  
  187.    [1]Any resemblance to the real product  is  purely  coin-
  188. cidental.
  189.    [2]Once upon a time it worked.  The code has  since  then
  190. not  been maintained.  So it is not implemented in most ver-
  191. sions.
  192.  
  193.  
  194.  
  195.  
  196. February 9, 1987    IFP 0.5 Users Manual                   2
  197.  
  198.  
  199. faster than previous FP implementations.
  200.  
  201.  
  202. _2.  _P_r_e_r_e_q_u_i_s_i_t_e_s
  203.  
  204.  
  205.      The rest of the manual  assumes  the  reader  has  read
  206.  
  207. Backus'  original paper on FP.  [Bac78a] Other references on
  208.  
  209. FP [Bad83a,Dar82a] may be of help.  Additionally,  parts  of
  210.  
  211. the  manual  assume  the reader understands UNIX or MSDOS[3]
  212.  
  213. file structure and paths.
  214.  
  215.  
  216. _2._1.  _O_r_g_a_n_i_z_a_t_i_o_n
  217.  
  218.  
  219.      IFP organizes functions in a tree  structure  analogous
  220.  
  221. to  UNIX/MSDOS files.  In fact each function is a file.  For
  222.  
  223. UNIX systems, each user specifies the root (``IFP root'') of
  224.  
  225. their function tree.  Within IFP, paths specify a path rela-
  226.  
  227. tive to the IFP root.   The  IFP  root  is  set  by  a  UNIX
  228.  
  229. environment  variable.   For  MSDOS systems, the IFP root is
  230.  
  231. identical to the current drive root.   (see  ``Environment''
  232.  
  233. below).
  234.  
  235.  
  236.      Each node on the tree is either a  function  definition
  237.  
  238. (corresponding  to  a file), or a module (corresponding to a
  239.  
  240. directory).  A function may reference another function via a
  241.  
  242. path.
  243.  
  244.  
  245.      To avoid having to write out  the  entire  path  for  a
  246.  
  247. function  every time, IFP has a function identifier importa-
  248.  
  249. tion feature.  Functions from other modules may be  imported
  250.  
  251. into  a module.  Once imported, a function may be referenced
  252.  
  253.  
  254.  
  255.  
  256. February 9, 1987    IFP 0.5 Users Manual                   3
  257.  
  258.  
  259. as though it were defined in the module.
  260.  
  261.  
  262. _2._2.  _E_n_v_i_r_o_n_m_e_n_t (_U_N_I_X)
  263.  
  264.  
  265.      Before invoking IFP, two environment  variables  should
  266.  
  267. be set. The ``EDITOR'' variable should be set to the name of
  268.  
  269. your favorite editor.  The ``IFProot''  variable  should  be
  270.  
  271. set to the  absolute  path  of  your  ``IFP  root''.[3]  The
  272.  
  273. ``IFPprompt''  is  optional.   If  set,  it  changes the IFP
  274.  
  275. prompt.  The default prompt is ``ifp>  ''.   Normally  these
  276.  
  277. variables  will  be  set  by  your .login file.  Below is an
  278.  
  279. example of the commands which would appear  in  your  .login
  280.  
  281. file.
  282.  
  283.        setenv EDITOR = ``/usr/ucb/vi''
  284.        setenv IFProot = ``/mnt/bonzo/fproot''
  285.        setenv IFPprompt = ``ifp> ''
  286.  
  287.  
  288. _2._3.  _E_n_v_i_r_o_n_m_e_n_t (_M_S_D_O_S)
  289.  
  290.  
  291.      Before invoking IFP, two environment  variables  should
  292.  
  293. be  set.   The ``EDITOR'' and ``IFPDIR'' variables should be
  294.  
  295. set to the names of your favorite editor and directory  lis-
  296.  
  297. ters  respectively.   Normally  these  should be set by your
  298.  
  299. autoexec.bat file, e.g.:
  300.  
  301.             set EDITOR=C:ED.EXE
  302.             set IFPDIR=C:SD2.COM
  303.  
  304. Unlike the UNIX version, there is no IFProot variable.   The
  305.  
  306. ____________________
  307.  
  308.    Use the actual path,  not  a  symbolic  link.   When  IFP
  309. starts  up,  it assumes that the current directory path is a
  310. prefix of the IFP root path.
  311.  
  312.  
  313.  
  314.  
  315. February 9, 1987    IFP 0.5 Users Manual                   4
  316.  
  317.  
  318. root of the IFP file system  is  the  root  of  the  current
  319.  
  320. drive.
  321.  
  322.  
  323. _3.  _U_s_i_n_g _I_F_P
  324.  
  325.  
  326. _3._1.  _S_t_a_r_t_i_n_g _I_F_P
  327.  
  328.  
  329.      To start an IFP session, change  your  current  working
  330.  
  331. directory  to  a  directory  under your IFP root.  Then type
  332.  
  333. "ifp".  Your current  working  directory  becomes  your  IFP
  334.  
  335. current  working  module. When IFP is ready, it will respond
  336.  
  337. with the prompt ``ifp> ''.  To end  the  IFP  session,  type
  338.  
  339. control-D or enter the command ``exit''.
  340.  
  341.  
  342. _3._2.  _C_r_e_a_t_i_n_g _a_n_d _E_d_i_t_i_n_g _D_e_f_i_n_i_t_i_o_n_s
  343.  
  344.  
  345.      To edit an IFP definition, type the command:
  346.  
  347.              vi[4] foo
  348.  
  349. where foo is the name of the function  to  be  edited.   The
  350.  
  351. function  may be one local to the current working module, or
  352.  
  353. one that is imported into the current  working  module.   If
  354.  
  355. the  function  name is neither defined locally nor imported,
  356.  
  357. then it is assumed to be a new local function.  To delete an
  358.  
  359. IFP definition, type the command:
  360.  
  361.              rm[5] foo
  362.  
  363.  
  364. ____________________
  365.  
  366.    [4]If your editor is not ``vi'' (as specified by the last
  367. element  of  your  EDITOR  path),  replace  ``vi'' with your
  368. editor's name.  For MS-DOS, the command is always ``ed'', no
  369. matter what the editor is called.
  370.  
  371.  
  372.  
  373.  
  374. February 9, 1987    IFP 0.5 Users Manual                   5
  375.  
  376.  
  377. _3._3.  _A_p_p_l_y_i_n_g _F_u_n_c_t_i_o_n_s
  378.  
  379.  
  380.      To apply an FP function, type the command[6]:
  381.  
  382.           show object : function
  383.  
  384. The  interpreter  evaluates  the  result  of  applying   the
  385.  
  386. function  to  the object.  The result is then pretty-printed
  387.  
  388. at the terminal.  Below are some example inputs and outputs.
  389.  
  390. show <a b c> : reverse
  391.  
  392. <c b a>
  393.  
  394. show <1 2 3> : sum
  395.  
  396. 6
  397.  
  398. show <1 2 3> : EACH [id,id]|* END | sum     (* sum of squares *)
  399.  
  400. 14
  401.  
  402. show <1 2 3 4 5> : EACH iota END
  403.  
  404. <
  405.      <1>
  406.      <1,2>
  407.      <1,2,3>
  408.      <1,2,3,4>
  409.      <1,2,3,4,5>
  410. >
  411.  
  412. exit
  413.  
  414.  
  415. _3._4.  _E_x_e_c_u_t_i_n_g _U_N_I_X _C_o_m_m_a_n_d_s
  416.  
  417.  
  418.      If a command is not recognized by the IFP  interpreter,
  419.  
  420. then  it  is  passed  on to the UNIX shell ``sh''.  Commands
  421.  
  422. such as ``ls'' and  ``more''  work  as  expected.   Commands
  423.  
  424. which  change  environment  do  not  work  properly, as they
  425. ____________________
  426.  
  427.    [5]For MS-DOS, the command is ``del''.
  428.    [6]Some earlier versions (before 0.4, e.g. the  BYTE  BIX
  429. release) require a semicolon after the _f_u_n_c_t_i_o_n.
  430.  
  431.  
  432.  
  433.  
  434. February 9, 1987    IFP 0.5 Users Manual                   6
  435.  
  436.  
  437. change their environment (within ``sh'') but not  your  own.
  438.  
  439. For example, the ``cd'' command does not work.
  440.  
  441.  
  442. _3._5.  _E_x_e_c_u_t_i_n_g _M_S_D_O_S _C_o_m_m_a_n_d_s
  443.  
  444.  
  445.      The only two MSDOS command that can be run from  within
  446.  
  447. the  interpreter are ``dir'' and ``del''.  Some systems seem
  448.  
  449. to require ``dir/''.  I don't know why.
  450.  
  451.  
  452.  
  453. _4.  _L_a_n_g_u_a_g_e
  454.  
  455.  
  456.      IFP semantics  are  almost  identical  to  Backus'  FP,
  457.  
  458. though  the syntax is quite different. The IFP language con-
  459.  
  460. sists of objects, functions, and functional forms.  The sin-
  461.  
  462. gle operation is _a_p_p_l_y which maps a function and object into
  463.  
  464. a new object.
  465.  
  466.  
  467. _4._1.  _O_b_j_e_c_t_s
  468.  
  469.  
  470.      Objects in FP are either atoms, sequences,  or  _b_o_t_t_o_m.
  471.  
  472. The  latter  is  a special object which denotes an undefined
  473.  
  474. value.  Atoms  are  numbers,  strings,  or  boolean  values.
  475.  
  476. Strings  must  be quoted when they look like another kind of
  477.  
  478. atom or contain non-alphanumeric  characters.   Below  is  a
  479.  
  480. table of some typical atoms:
  481.  
  482.  
  483.        banana                 string
  484.        "The cat in the hat"   string (double quotes)
  485.        'hello world'          string (single quotes)
  486.        7                      number
  487.        3.1415                 number
  488.        1e6                    number (million)
  489.  
  490.  
  491.  
  492.  
  493. February 9, 1987    IFP 0.5 Users Manual                   7
  494.  
  495.  
  496.        "1.414"                string
  497.        t                      boolean true
  498.        f                      boolean false
  499.        "t"                    string
  500.  
  501.  
  502.  
  503.      Sequences are lists of zero or more objects  surrounded
  504.  
  505. by angle brackets.  Sequences are written as:
  506.  
  507.  
  508.                <x ,x ,...x >
  509.              1  2     n
  510. Below is table of some typical sequences:
  511.  
  512.  
  513.          <a,b,c>
  514.          <1 2 3 4 5 6>
  515.          <>
  516.          <<1 2 3> <apple banana> t>
  517.  
  518.  
  519. Either commas or spaces may be used to separate the elements
  520.  
  521. of a sequence.  The elements of the sequence may be any kind
  522.  
  523. of object except ``?'', and do not have to be  of  the  same
  524.  
  525. type.
  526.  
  527.  
  528.      IFP sequences have the _b_o_t_t_o_m _p_r_e_s_e_r_v_i_n_g [_B_a_c_7_8_a]  pro-
  529.  
  530. perty.   Any  sequence  containing  ``?'' is itself equal to
  531.  
  532. ``?''.
  533.  
  534.  
  535.  
  536. _4._2.  _F_u_n_c_t_i_o_n_s
  537.  
  538.  
  539.      Functions in FP always have a  single  argument  and  a
  540.  
  541. single  result.  FP functions are analogous to UNIX programs
  542.  
  543. which transform ``standard input'' into ``standard  output''
  544.  
  545. without side effects.
  546.  
  547.  
  548.  
  549.  
  550. February 9, 1987    IFP 0.5 Users Manual                   8
  551.  
  552.  
  553.      The IFP interpreter distinguishs  two  kinds  of  func-
  554.  
  555. tions:   primitive  functions  and  user-defined  functions.
  556.  
  557. Primitive functions  are  built  into  the  FP  interpreter;
  558.  
  559. user-defined  functions  are  created by the user.  The only
  560.  
  561. distinction between the  two  kinds  of  functions  is  that
  562.  
  563. user-defined  functions  have  definitions in terms of other
  564.  
  565. IFP functions.  All  functions  may  be  used  in  the  same
  566.  
  567. manner,  neither  primitive  nor  user-defined functions are
  568.  
  569. privileged in any way.
  570.  
  571.  
  572.      IFP functions are arranged in a tree  structure  analo-
  573.  
  574. gous  to  the way UNIX files are arranged.  Each node of the
  575.  
  576. tree is either a module (directory) or function  (file).   A
  577.  
  578. function  is referenced by its _p_a_t_h_n_a_m_e, which is a sequence
  579.  
  580. of node names separated by slashes.   Pathnames  follow  the
  581.  
  582. UNIX  conventions.  Absolute  pathnames  begin with a slash,
  583.  
  584. which indicates that the path starts at the IFP root  direc-
  585.  
  586. tory  (as specified by the IFProot variable in your environ-
  587.  
  588. ment).  Relative pathnames do not begin with a slash,  which
  589.  
  590. indicates  that  the  path  starts at the current directory.
  591.  
  592. Within function definitions, the current  directory  is  the
  593.  
  594. parent  node of the function.  Pathnames may contain ``..'',
  595.  
  596. which indicates moving up to the parent node.
  597.  
  598.  
  599.      For example, consider the node tree in Figure  1.   The
  600.  
  601. root node is ``r''.  Below are some ways the function  ``b''
  602.  
  603. can  reference  the  other nodes.  Note that the name of the
  604.  
  605. root node is never explicitly used.
  606.  
  607.  
  608.  
  609.  
  610. February 9, 1987    IFP 0.5 Users Manual                   9
  611.  
  612.  
  613.  
  614.                 +-----+
  615.                 |  r  |
  616.                 +-----+
  617.                    /       \
  618.                   /         \
  619.                  /           \
  620.                 /             \
  621.                /               \
  622.               /                 \
  623.              +-----+               +-----+
  624.              | tmp |               | sys |
  625.              +-----+               +-----+
  626.             /   |   \               /   \
  627.            /    |    \             /     \
  628.           /     |     \           /       \
  629.          /      |      \         /         \
  630.          +-----+ +-----+ +-----+  +-----+     +-----+
  631.          | foo | |  a  | |  b  |  | id  |     | sum |
  632.          +-----+ +-----+ +-----+  +-----+     +-----+
  633.           /   \
  634.          /     \
  635.         /       \
  636.     +-----+    +-----+
  637.     |  p  |    |  q  |
  638.     +-----+    +-----+
  639.               Figure 1
  640.  
  641.  
  642.          _________________________
  643.         |_p_a_t_h_n_a_m_e________t_y_p_e______|
  644.         | /sys/sum       absolute|
  645.         | /tmp/foo/p     absolute|
  646.         | foo/p          relative|
  647.         | ../tmp/foo/p   relative|
  648.         | ../sys/sum     relative|
  649.         |_________________________|
  650.  
  651.  
  652.  
  653. _4._2._1.  _P_r_i_m_i_t_i_v_e _F_u_n_c_t_i_o_n_s
  654.  
  655.  
  656.      Primitive functions are built into the IFP interpreter.
  657.  
  658. They  have  pathnames  like  any other function, except that
  659.  
  660. there is no source code file for the function.  The function
  661.  
  662. descriptions  are grouped into sections below.  The pathname
  663.  
  664. for the function's module is in parentheses at  the  top  of
  665.  
  666.  
  667.  
  668.  
  669. February 9, 1987    IFP 0.5 Users Manual                  10
  670.  
  671.  
  672. each section.[7]
  673.  
  674.  
  675.      The following sets (types) are used in the  definitions
  676.  
  677. of functions:
  678.  
  679.  
  680.     A         atoms
  681.     B         boolean values
  682.     O         objects
  683.     R         real numbers
  684.     Z         integers
  685.     S         strings
  686.     T*        sequences with element type T
  687.     T+        non-empty sequences with element type T
  688.     Tn        sequences of length n with element type T
  689.     T[n,m]    sequences of length m with element type Tn
  690.     [T ,T ]   pair of types T  and T
  691.       1  2                   1      2
  692.  
  693. A function returns ``?'' if  the  argument  is  not  in  its
  694.  
  695. domain.   The  notation  x   denotes  the  nth  element of a
  696.               n
  697. sequence X.
  698.  
  699.  
  700.      For example, the domain of  the  addition  function  is
  701.  
  702. [X,Y]  in  [R,R].   That  is  addition  takes a pair of real
  703.  
  704. numbers as its argument.  We could also write this as  [X,Y]
  705.  
  706. in R2, since a pair is a sequence of length two.
  707.  
  708.  
  709.      The types may be pictured neatly with the Venn  diagram
  710.  
  711. in Figure 2:
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719. ____________________
  720.  
  721.    [7] NOTE: The author does not worship  backward  compati-
  722. bility.   Future versions of IFP may put primitive functions
  723. in different subdirectories.
  724.  
  725.  
  726.  
  727.  
  728. February 9, 1987    IFP 0.5 Users Manual                  11
  729.  
  730.  
  731.  
  732.       +----------------------------+
  733.       | O                          |
  734.       |   +--------------------+   |
  735.       |   |  A                 |   |
  736.       |   |    +-----------+   |   |
  737.       |   |    |     B     |   |   |
  738.       |   |    +-----------+   |   |
  739.       |   |    | R         |   |   |
  740.       |   |    |   +---+   |   |   |
  741.       |   |    |   | Z |   |   |   |
  742.       |   |    |   +---+   |   |   |
  743.       |   |    |           |   |   |
  744.       |   |    +-----------+   |   |
  745.       |   |    |     O*    |   |   |
  746.       |   |    +-----------+   |   |
  747.       |   |                    |   |
  748.       |   +--------------------+   |
  749.       |                            |
  750.       | +-+                        |
  751.       | |?|                        |
  752.       | +-+                        |
  753.       |                            |
  754.       +----------------------------+
  755.               Figure 2
  756.  
  757.  
  758. _4._2._1._1.  _S_t_r_u_c_t_u_r_a_l _F_u_n_c_t_i_o_n_s (/_s_y_s)
  759.  
  760.  
  761.      Structural  functions  are  assemble,  reorganize,  and
  762.  
  763. select  data.  The primitive structural functions are listed
  764.  
  765. below:
  766.  
  767.  
  768.  
  769.  
  770. February 9, 1987    IFP 0.5 Users Manual                  12
  771.  
  772.  
  773. __________________________________________________________________________
  774. _|N_a_m_e_______D_o_m_a_i_n_________________D_e_f_i_n_i_t_i_o_n________________________________|
  775. |                                                                        |
  776. |apndl     [X,Y] in [O,On]       <X,y ,y ,...y >                         |
  777. |                                    1  2     n                          |
  778. |apndr     [X,Y] in [Om,O]       <x  x ,...x ,Y>                         |
  779. |                                  1, 2     m                            |
  780. |                nm                                                      |
  781. |cat       X in O                catenate subsequences, e.g.             |
  782. |                                <<a b> <x> <3 5>> -> <a b x 3 5>        |
  783. |                       n                                                |
  784. |distl     [X,Y] in [O,O ]       <<X,y1><X,y2>...<X,yn>>                 |
  785. |                     m                                                  |
  786. |distr     [X,Y] in [O ,O]       <<x1,Y><x2,Y>...<xm,Y>>                 |
  787. |                     n                                                  |
  788. |dropl     [X,K] in [O ,0<_Z<_n]   <xK+1,xK+2,...xn>                       |
  789. |                     n                                                  |
  790. |dropr     [X,K] in [O ,0<_Z<_n]   <x1,x2,...xn-k>                         |
  791. |                                                                        |
  792. |iota      n in Z>_0              <1,2,...n>                              |
  793. |                n                                                       |
  794. |length    X in O                n                                       |
  795. |                     n                                                  |
  796. |pick      [X,K] in [O ,0<Z<_n]   xK                                      |
  797. |                                                                        |
  798. |repeat    [X,K] in [O,0<_Z]      sequence <X,X...X> of length K          |
  799. |                n                                                       |
  800. |reverse   X in O                <xn,xn-1,...x1>                         |
  801. |                     n                                                  |
  802. |takel     [X,K] in [O ,0<_Z<_n]   <x1,x2,...xK>                           |
  803. |                     n                                                  |
  804. |taker     [X,K] in [O ,0<_Z<_n]   <xn-K+1,xn-k+2,...xn>                   |
  805. |                m>0                                                     |
  806. |tl        X in O                <x2,x3,...xm>                           |
  807. |                m>0                                                     |
  808. |tlr       X in O                <x1,x2,...xm-1>                         |
  809. |                [n,m]                                                   |
  810. |trans     X in O                transpose matrix, e.g.                  |
  811. _||________________________________<_<_a__1_>__<_b__2_>__<_c__3_>_>__-_>__<_<_a__b__c_>__<_1__2__3_>_>
  812.  
  813.  
  814.  
  815. _4._2._1._2.  _A_r_i_t_h_m_e_t_i_c (/_m_a_t_h/_a_r_i_t_h)
  816.  
  817.  
  818.      Most IFP arithmetic functions are found here.  Below is
  819.  
  820. a  table  of the existing functions.  Some function's domain
  821.  
  822. may be further restricted due to range limitations.
  823.  
  824.  
  825.  
  826.  
  827. February 9, 1987    IFP 0.5 Users Manual                  13
  828.  
  829.  
  830. _______________________________________________________________
  831. _|N_a_m_e______D_o_m_a_i_n______________D_e_f_i_n_i_t_i_o_n_________________________|
  832. |                                                             |
  833. |+        [X,Y] in [R,R]     X+Y                              |
  834. |                                                             |
  835. |-        ...                X-Y                              |
  836. |                                                             |
  837. |*        ...                XxY                              |
  838. |                                                             |
  839. |%        [X,Y] in [R,R=/0]   X/Y                              |
  840. |                                                             |
  841. |add1     X in R             X+1                              |
  842. |                                                             |
  843. |arcsin   X in R, -1<_X<_1     arcsinX                          |
  844. |                                                             |
  845. |arccos   X in R, -1<_X<_1     arccosX                          |
  846. |                                                             |
  847. |arctan   X in R             arctanX                          |
  848. |                                                             |
  849. |cos      X in R             cosX                             |
  850. |                                                             |
  851. |div      [X,Y] in [R,R=/0]   floor(X/Y)                       |
  852. |                                                             |
  853. |exp      X in R             eX                               |
  854. |                                                             |
  855. |ln       X in R>0           log X                            |
  856. |                               e                             |
  857. |max      [X,Y] in [R,R]     max(X,Y)                         |
  858. |                                                             |
  859. |min      [X,Y] in [R,R]     min(X,Y)                         |
  860. |                                                             |
  861. |minus    X in R             -X                               |
  862. |                                                             |
  863. |mod      [X,Y] in [R,R]     X-Yfloor(X/Y) if Y=/0, 0 otherwise|
  864. |                                                             |
  865. |power    [X,Y] in [R>_0,R]   XY                               |
  866. |                                                             |
  867. |sin      X in R             sinX                             |
  868. |                              _                              |
  869. |sqrt     X in R>0           \|X                              |
  870. |                                                             |
  871. |sub1     X in R             X-1                              |
  872. |                                                             |
  873. |sum      X in R*            X +X +...+X                      |
  874. |                             1  2      n                     |
  875. |tan      X in R             tanX                             |
  876. _|______________________________________________________________|
  877.  
  878.  
  879.  
  880.  
  881. February 9, 1987    IFP 0.5 Users Manual                  14
  882.  
  883.  
  884. _4._2._1._3.  _L_o_g_i_c (/_m_a_t_h/_l_o_g_i_c)
  885.  
  886.  
  887.      Most IFP primitive functions returning  boolean  values
  888.  
  889. are found here.  Below is a table of the existing functions:
  890.  
  891.  
  892.  
  893.  
  894. February 9, 1987    IFP 0.5 Users Manual                  15
  895.  
  896.  
  897.        ______________________________________________
  898.       |_N_a_m_e_______D_o_m_a_i_n__________________D_e_f_i_n_i_t_i_o_n___|
  899.       |                                             |
  900.       | =         [X,Y] in [O,O]         X=Y        |
  901.       |                                             |
  902.       | ~=        ...                    X=/Y        |
  903.       |                                             |
  904.       | <         [X,Y] in [R,R]U[S,S]   X<Y        |
  905.       |                                             |
  906.       | <=        ...                    X<_Y        |
  907.       |                                             |
  908.       | >=        ...                    X>_Y        |
  909.       |                                             |
  910.       | >         ...                    X>Y        |
  911.       |                                             |
  912.       | ~         X in B                 ~X         |
  913.       |                                             |
  914.       | and       [X,Y] in [B,B]         X/\Y       |
  915.       |                                             |
  916.       | all       X in B*                /\x        |
  917.       |                                  k  k       |
  918.       |                                             |
  919.       | any       X in B*                \/xk       |
  920.       |                                  k          |
  921.       | atom      X in O                 X in A     |
  922.       |                                             |
  923.       | boolean   X in O                 X in B     |
  924.       |                                             |
  925.       | false     X in O                 X=#f       |
  926.       |                                             |
  927.       | imply     [X,Y] in [B,B]         ~X\/Y      |
  928.       |                                             |
  929.       | longer    [X,Y] in [Om,On]       m>n        |
  930.       |                                             |
  931.       | member    [X,Y] in [O*,O]        Y in X     |
  932.       |                                             |
  933.       | numeric   X in O                 X in R     |
  934.       |                                             |
  935.       | null      X in O*                X=<>       |
  936.       |                                             |
  937.       | odd       X in Z                 X mod 2 = 1|
  938.       |                                             |
  939.       | or        [X,Y] in [B,B]         X\/Y       |
  940.       |                                             |
  941.       | pair      X in O                 X in [O,O] |
  942.       |                                             |
  943.       | shorter   [X,Y] in [Om,On]       m<n        |
  944.       |                                             |
  945.       | xor       [X,Y] in [B,B]         X=/Y        |
  946.       |______________________________________________|
  947.  
  948.  
  949. String  inequalities  are  defined  from  the  lexigraphical
  950.  
  951.  
  952.  
  953.  
  954. February 9, 1987    IFP 0.5 Users Manual                  16
  955.  
  956.  
  957. (dictionary) ordering.
  958.  
  959.  
  960. _4._2._1._4.  _S_t_r_i_n_g _F_u_n_c_t_i_o_n_s (/_s_y_s)
  961.  
  962.  
  963.      The string functions are:
  964.  
  965.  
  966. ____________________________________________________________
  967. _|N_a_m_e_______D_o_m_a_i_n_____D_e_f_i_n_i_t_i_o_n______________________________|
  968. |                                                          |
  969. |explode   X in S    sequence of characters in X           |
  970. |                                                          |
  971. |implode   X in S*   string made by catenating strings in X|
  972. |                                                          |
  973. |patom     X in A    string representation of X, e.g.      |
  974. |                    123 : patom -> "123"                  |
  975. _|___________________________________________________________|
  976.  
  977.  
  978.  
  979. _4._2._1._5.  _M_i_s_c_e_l_l_a_n_e_o_u_s _F_u_n_c_t_i_o_n_s (/_s_y_s)
  980.  
  981.  
  982.      The miscellaneous functions  are  listed  below.   Each
  983.  
  984. function  description  is  preceded  by  a title line of the
  985.  
  986. form:
  987.  
  988. ____________________________________________________________
  989.  
  990.  
  991. function                   domain                 definition
  992.  
  993.  
  994. ____________________________________________________________
  995.  
  996.  
  997. apply                 [X,F] in [O,S*]           apply F to X
  998.  
  999.  
  1000.     F is a sequence of strings representing  a  pathname
  1001.     to  a  defined function.  The result is the function
  1002.     referenced by F applied to X.  Example:
  1003.  
  1004.          <<3 4> <math arith "+">> : apply -> 7
  1005.  
  1006.     F may also be an anonymous  function.   Anonymous  func-
  1007.     tions are objects that are enclosed by parentheses.  For
  1008.     instance, the previous example could be written as
  1009.  
  1010.  
  1011.  
  1012.  
  1013. February 9, 1987    IFP 0.5 Users Manual                  17
  1014.  
  1015.  
  1016.             <<3 4> (+)> : apply -> 7
  1017.  
  1018.     Functions built from functional forms may  also  be  ob-
  1019.     jects, for example:
  1020.  
  1021.     <<<1 2 3> <4 5 6>> (trans|EACH * END|sum) -> 32
  1022.  
  1023.     Function objects are considered to be atomic.  Functions
  1024.     that  act on sequences will not behave properly when ap-
  1025.     plied to a function object.  The ``apply'' function com-
  1026.     bined with function objects lets us define our own func-
  1027.     tional forms.  For example, we can define  a  functional
  1028.     form Twice which applies a function twice as:
  1029.  
  1030.          DEF Twice AS [apply,2]|apply;
  1031.  
  1032.     Then we can write:
  1033.  
  1034.           3 : [id,([id,id]|*)] | Twice -> 81
  1035.  
  1036.     ________________________________________________________
  1037.  
  1038. assoc               [X,Y] in [(O+)*,O]    associative lookup
  1039.  
  1040.  
  1041.     X is an association sequence,  which  is  a  se-
  1042.     quence  of  non-empty  subsequences.   The first
  1043.     element of each subsequence is the  _k_e_y  of  the
  1044.     subsequence.   The  result of assoc is the first
  1045.     subsequence of X with a key equal to Y.   If  no
  1046.     matching  key  is found, f is returned.  The key
  1047.     may be any type of object.  Examples:
  1048.  
  1049.          <<<a b c> <w x y z> <i j>> w> -> <w x y z>
  1050.          <<<a b c> <w x y z> <i j>> U> -> f
  1051.  
  1052.  
  1053.     ____________________________________________________
  1054.  
  1055. def                       X in S+                 definition
  1056.  
  1057.  
  1058.         The definition function returns  the  object
  1059.         representation   of   its   argument.    The
  1060.         representation of a function is  a  sequence
  1061.         of  strings  denoting its absolute pathname.
  1062.         The representation of a functional form is a
  1063.         sequence.  The first element of the sequence
  1064.         is a pathname to the functional  form.   The
  1065.         remaining   elements  of  the  sequence  are
  1066.         parameters of the functional form.  Suppose,
  1067.         for  example,  we  define  the inner product
  1068.         function:
  1069.  
  1070.  
  1071.  
  1072.  
  1073. February 9, 1987    IFP 0.5 Users Manual                  18
  1074.  
  1075.  
  1076.          DEF Inner AS trans | EACH * END | INSERT + END
  1077.  
  1078.         and ``Inner'' is  defined  with  a  module  with
  1079.         pathname  ``/math/linear''.  Then ``<math linear
  1080.         Inner> : def'' will result in:
  1081.  
  1082.           <
  1083.                <sys compose>
  1084.                <sys trans>
  1085.                <<sys each> <math arith *>>
  1086.                <<sys insertr> <math arith +>>
  1087.           >
  1088.  
  1089.         Currently,  the  representations  of  functional
  1090.         forms are:
  1091.  
  1092.     ________________________________________________________
  1093.        | #c                       <<sys constant> #c>          |
  1094.        | #?                       <<sys constant>>             |
  1095.        | n                        <<sys select> n>             |
  1096.        | nr                       <<sys select> -n>            |
  1097.        | f1|f2|...fn              <<sys compose>, f1,f2,...fn  |
  1098.        | [f1,f2,...fn]            <<sys construct>, f1,f2,...fn|
  1099.        | ^c                       <<sys fetch> c>              |
  1100.        | EACH f END               <<sys each> f>               |
  1101.        | FILTER p END             <<sys filter> p>             |
  1102.        | INSERT f END             <<sys insertr> f>            |
  1103.        | IF p THEN g ELSE h END   <<sys if> p g h>             |
  1104.        ||_W_H_I_L_E__p__D_O__f__E_N_D__________<_<_s_y_s__w_h_i_l_e_>__p__f_>______________||
  1105.  
  1106.         ELSIF   clauses   are   always   expanded   into
  1107.         equivalent  nested  IF-THEN-ELSE  constructions.
  1108.         Note the special case for #?, the representation
  1109.         <<sys  constant>  ?> would be useless due to the
  1110.         bottom-preserving property.
  1111.  
  1112.         ________________________________________________
  1113.  
  1114. id                        X in O                    identity
  1115.  
  1116.  
  1117.         The identity function returns its  argu-
  1118.         ment.  It is useful as a place holder in
  1119.         functional  forms.   For  example,   the
  1120.         ``square'' function can be written as:
  1121.         DEF Square AS [id,id] | *;
  1122.  
  1123.  
  1124.  
  1125.  
  1126. February 9, 1987    IFP 0.5 Users Manual                  19
  1127.  
  1128.  
  1129. _4._2._2.  _U_s_e_r _D_e_f_i_n_e_d _F_u_n_c_t_i_o_n_s
  1130.  
  1131.  
  1132.      The user may define functions by  creating  defini-
  1133.  
  1134. tion files (source code).  The definition in the file is
  1135.  
  1136. of the form:
  1137.  
  1138.             DEF _f_o_o AS _b_a_r;
  1139.  
  1140. where _f_o_o is the name of the function and _b_a_r is the de-
  1141.  
  1142. finition.   The  name of the file must also be _f_o_o.  The
  1143.  
  1144. definition may be any IFP function.   For  example,  you
  1145.  
  1146. can define the square function as:
  1147.  
  1148.     DEF Square AS [/sys/id,/sys/id] | /math/arith/*;
  1149.  
  1150.  
  1151.      Writing out the entire pathname of functions is not
  1152.  
  1153. necessary.   If the function is defined in the same sub-
  1154.  
  1155. directory, then just its  name  is  necessary.   If  the
  1156.  
  1157. function  is  defined  in another subdirectory, then you
  1158.  
  1159. can ``import'' it.  An imported function can  be  refer-
  1160.  
  1161. enced  as  though  it were defined in the directory into
  1162.  
  1163. which it is imported.  To import functions into  a  sub-
  1164.  
  1165. directory,  you  create an ``import file'' with the name
  1166.  
  1167. %IMPORT with the editor.  The form of the  %IMPORT  file
  1168.  
  1169. is:
  1170.  
  1171.      FROM directory  IMPORT f ,f , ... f ;
  1172.      FROM directory1 IMPORT g1,g2, ... gn;
  1173.           ...      2         1  2       m
  1174.  
  1175. The directory is a pathname to a directory.   For  exam-
  1176.  
  1177. ple, typical import file might be:
  1178.  
  1179.  
  1180.     FROM /sys IMPORT apndr,distl,id,iota,takel;
  1181.  
  1182.  
  1183.  
  1184.  
  1185. February 9, 1987    IFP 0.5 Users Manual                  20
  1186.  
  1187.  
  1188.     FROM /math/arith IMPORT +,-,*,%;
  1189.  
  1190. Since the function ``id'' is imported, the  square  function
  1191. can be defined as:
  1192.          DEF Square AS [id,id] | *;
  1193.  
  1194.  
  1195. _4._2._3.  _F_u_n_c_t_i_o_n_a_l _V_a_r_i_a_b_l_e_s
  1196.  
  1197.  
  1198.      Functional variables [Bac81a] are locally defined func-
  1199.  
  1200. tions with special scope rules. A functional variable defin-
  1201.  
  1202. ition is written:
  1203.  
  1204.              {_l_h_s := _f_u_n_c_t_i_o_n}
  1205.  
  1206. where _l_h_s (left hand side) is either a function name or con-
  1207.  
  1208. struction  of  _l_h_s's.   All function names in the _l_h_s become
  1209.  
  1210. functional variables within their scope.  The scope is _b_o_u_n_-
  1211.  
  1212. _d_a_r_y  _s_t_r_u_c_t_u_r_e_d as opposed to block structured, which means
  1213.  
  1214. that the variables may be seen only  through  certain  boun-
  1215.  
  1216. daries.   The  scope  rules  can be defined by the following
  1217.  
  1218. transformations:
  1219.  
  1220.  {V := h} v -> h | V -1
  1221.             v
  1222.  {V := h} [f ,f ,...] -> [{V := h} f , {V := h} f , ...]
  1223.         1  2                    1            2
  1224.  {V := h} IF p THEN x       IF {V := h} p THEN {V := h} x
  1225.       ELSE y        ->   ELSE {V := h} y
  1226.       END               END
  1227.  
  1228. where -> indicates that the left side may be  simplified  to
  1229.  
  1230. the  right  side.  ``V'' denotes a left-hand side containing
  1231.  
  1232. the functional variable ``v''.  V -1 is the inversion  func-
  1233.                  v
  1234. tion  of ``V'' for ``v''.  For example, if V = [a,b,c], then
  1235.  
  1236. V -1 = 3. Variables must be defined before use.   Note  that
  1237.  c
  1238. the vertical bar of composition cuts off the scope, e.g. in
  1239.  
  1240.             {[_x,_y] := id} _g | _h
  1241.  
  1242.  
  1243.  
  1244.  
  1245. February 9, 1987    IFP 0.5 Users Manual                  21
  1246.  
  1247.  
  1248. the function _g can ``see'' _x and _y, but _h can not.
  1249.  
  1250.  
  1251.      An example of a definition  with  functional  variables
  1252.  
  1253. appears below:
  1254.  
  1255. (*
  1256.  * InsertSort
  1257.  *
  1258.  * This function sorts a sequence of numbers or strings into ascending order
  1259.  * using insertion sort.
  1260.  *
  1261.  * Examples:
  1262.  *
  1263.  *      <3 1 4 1 5 9 2> : InsertSort == <1 1 2 3 4 5 9>
  1264.  *
  1265.  *      <all work and no play> : InsertSort == <all and no play work>
  1266.  *
  1267.  * The sequence may not mix strings and numbers.
  1268.  *)
  1269. DEF InsertSort AS
  1270.    IF null THEN id     (* Check for trivial case *)
  1271.    ELSE
  1272.       [tl,[1]] | apndr |
  1273.       INSERT
  1274.      {[Element,Seq] := id}
  1275.      {[Left,Right] := [Seq, distl | FILTER > END | length] | [takel,dropl]}
  1276.      [Left,[Element],Right] | cat
  1277.       END
  1278.    END;
  1279.  
  1280. In this example, _E_l_e_m_e_n_t, _S_e_q, _L_e_f_t, and _R_i_g_h_t are function-
  1281.  
  1282. al variables.
  1283.  
  1284.  
  1285.  
  1286. _4._3.  _F_u_n_c_t_i_o_n_a_l _F_o_r_m_s
  1287.  
  1288.  
  1289.      Functional  forms  combine  functions  and  objects  to
  1290.  
  1291. create new functions.
  1292.  
  1293.  
  1294. _4._3._1.  _C_o_n_s_t_a_n_t
  1295.  
  1296.  
  1297.      Constant functions always return the same  result  when
  1298.  
  1299. applied to any value which is not ``?''.  Constant functions
  1300.  
  1301.  
  1302.  
  1303.  
  1304. February 9, 1987    IFP 0.5 Users Manual                  22
  1305.  
  1306.  
  1307. are written as:
  1308.  
  1309.                  #_c
  1310.  
  1311. where c is the constant value to  be  returned.  A  constant
  1312.  
  1313. function  applied  to ``?'' results in ``?''.  Note that the
  1314.  
  1315. function ``#?'' always returns `?'.  Examples:
  1316.  
  1317.         923 : #<cat in hat> -> <cat in hat>
  1318.         <a b c d e f> : #427 -> 427
  1319.         ? : #<q w er t y> -> ?
  1320.         5 : #? -> ?
  1321.  
  1322.  
  1323. _4._3._2.  _S_e_l_e_c_t_i_o_n
  1324.  
  1325.  
  1326.      Selector functions return the nth element of a sequence
  1327.  
  1328. and  are  written as n, where n is a positive integer.  Note
  1329.  
  1330. the distinction between #5, which returns the value  5,  and
  1331.  
  1332. 5,  which  returns  the fifth element of its argument. There
  1333.  
  1334. are also a corresponding set of select-from-right functions,
  1335.  
  1336. written  as  nr. These select the nth element of a sequence,
  1337.  
  1338. counting from the right. All selectors return ``?''  if  the
  1339.  
  1340. argument has no nth element or is not a sequence.  Below are
  1341.  
  1342. some examples of applying selector functions:
  1343.  
  1344.         <a b c d e> : 1 -> a
  1345.         <a b c d e> : 2 -> b
  1346.         <apple banana cherry> : 1r -> cherry
  1347.         <apple banana cherry> : 4 -> ?
  1348.         hello : 1 -> ?
  1349.  
  1350.  
  1351. _4._3._3.  _C_o_m_p_o_s_i_t_i_o_n
  1352.  
  1353.  
  1354.      The function composition of two  functions  is  written
  1355.  
  1356. as:
  1357.  
  1358.  
  1359.  
  1360.  
  1361. February 9, 1987    IFP 0.5 Users Manual                  23
  1362.  
  1363.  
  1364.                f | g
  1365.  
  1366. Applying the result function is the same as applying  f  and
  1367.  
  1368. then g.  E.g.: Function composition is defined by the equal-
  1369.  
  1370. ity:
  1371.  
  1372.  
  1373.          x : (f | g) =_ (x : f) : g
  1374.  
  1375. Since function composition is associative,  the  composition
  1376.  
  1377. of  more  than  two  functions does not require parentheses.
  1378.  
  1379. The composition of f ,f ,...f  is written:
  1380.             1  2     n
  1381.  
  1382.               f  | f  | ...f
  1383.                1    2       n
  1384. Composition syntax is identical to UNIX's pipe notation  for
  1385.  
  1386. a  reason:  function  composition  is  isomorphic  to a pipe
  1387.  
  1388. between processes without side effects.
  1389.  
  1390.  
  1391. _4._3._4.  _C_o_n_s_t_r_u_c_t_i_o_n
  1392.  
  1393.  
  1394.      The construction of functions is written  as  bracketed
  1395.  
  1396. list  of  the  functions.   For example, the construction of
  1397.  
  1398. functions f  is written:
  1399.        i
  1400.  
  1401.                [f ,f ,...f ]
  1402.              1  2     n
  1403. Function construction is defined by the equality:
  1404.  
  1405.  
  1406.       x : [f ,f ,...f ] =_ <x:f ,x:f ,...x:f >
  1407.         1  2     n        1    2       n
  1408.  
  1409. _4._3._5.  _A_p_p_l_y _t_o _E_a_c_h
  1410.  
  1411.  
  1412.      The EACH functional form applies  a  function  to  each
  1413.  
  1414. element of a sequence.  It is written as
  1415.  
  1416.              EACH _f END
  1417.  
  1418.  
  1419.  
  1420.  
  1421. February 9, 1987    IFP 0.5 Users Manual                  24
  1422.  
  1423.  
  1424. It is defined by the equality:
  1425.  
  1426.       <x ,x ,...x > : EACH f END =_ <x :f,x :f,...x :f>
  1427.     1  2     n                   1    2       n
  1428.  
  1429. _4._3._6.  _I_f-_T_h_e_n-_E_l_s_e
  1430.  
  1431.  
  1432.      The IF functional form allows conditional function  ap-
  1433.  
  1434. plication.  It is written as
  1435.  
  1436.            IF _p THEN _g ELSE _h END
  1437.  
  1438. and is defined by the equality:
  1439.  
  1440.  
  1441.                      | g(x) if p(x)=t
  1442.                      |
  1443.        x :IF p THEN g ELSE h END  -> | h(x) if p(x)=f
  1444.                      | ?    otherwise
  1445.                      |
  1446. The level of nesting of conditional forms may be reduced  by
  1447.  
  1448. using ELSIF clauses:
  1449.  
  1450.             IF p  THEN g
  1451.             ELSE1       1
  1452.                IF p  THEN g
  1453.                ELSE2       2
  1454.               IF p  THEN g
  1455.               ELSE3h      3
  1456.               END
  1457.                END
  1458.             END
  1459.  
  1460.  
  1461. _4._3._7.  _F_i_l_t_e_r
  1462.  
  1463.  
  1464.      The FILTER functional form filters through elements  of
  1465.  
  1466. a sequence satisfying a predicate.  It is written as:
  1467.  
  1468.             FILTER _p END
  1469.  
  1470. where p is the predicate.  It is defined by  the  functional
  1471.  
  1472. equality:
  1473.  
  1474.            EACH
  1475.           IF _p THEN [id] ELSE [] END
  1476.            END | cat
  1477.  
  1478.  
  1479.  
  1480.  
  1481. February 9, 1987    IFP 0.5 Users Manual                  25
  1482.  
  1483.  
  1484. For example, if you wish to find all numeric elements  in  a
  1485.  
  1486. sequence, you could write:
  1487.  
  1488.              FILTER numeric END
  1489.  
  1490. The FILTER functional form is an IFP  extension  to  Backus'
  1491.  
  1492. FP.
  1493.  
  1494.  
  1495. _4._3._8.  _R_i_g_h_t _I_n_s_e_r_t
  1496.  
  1497.  
  1498.      The INSERT functional form is defined by the recursion:
  1499.  
  1500. INSERT _f END =_ IF tl|null THEN 1 ELSE [1,tl | INSERT _f END] | _f END
  1501.  
  1502. Typically it is used for crunching a sequence down.  For ex-
  1503.  
  1504. ample,
  1505.  
  1506.             INSERT + END
  1507.  
  1508. returns the sum of a sequence.
  1509.  
  1510.  
  1511.      Unlike Backus' FP, functions formed with INSERT are al-
  1512.  
  1513. ways  undefined  for empty sequences.  The reason is that it
  1514.  
  1515. is impractical for the interpreter to know the identity ele-
  1516.  
  1517. ment  of  user-defined functions.  The number of cases where
  1518.  
  1519. the interpreter could know the identity element are  so  few
  1520.  
  1521. that  you  might  as well define special functions for those
  1522.  
  1523. cases, e.g:
  1524.  
  1525.      DEF sum AS IF null THEN #0 ELSE INSERT + END END;
  1526.  
  1527. Alternatively, you can append the identity  element  to  the
  1528.  
  1529. end of the sequence before inserting, e.g.:
  1530.  
  1531.      DEF sum AS [id,#0] | apndr | INSERT + END;
  1532.  
  1533.  
  1534.      Currently there is no ``left insert'' form.   The  left
  1535.  
  1536. insertion of f can be written as:
  1537.  
  1538.  
  1539.  
  1540.  
  1541. February 9, 1987    IFP 0.5 Users Manual                  26
  1542.  
  1543.  
  1544.            reverse | INSERT reverse|f END
  1545.  
  1546.  
  1547. _4._3._9.  _W_h_i_l_e
  1548.  
  1549.  
  1550.      The WHILE functional form  allows  indefinite  composi-
  1551.  
  1552. tion. It is written as:
  1553.  
  1554.              WHILE _p DO _f END;
  1555.  
  1556. and is defined by the recursive functional equality:
  1557.  
  1558.      WHILE _p DO _f END =_ IF _p THEN
  1559.                    _f | WHILE _p DO _f END
  1560.                  ELSE id
  1561.                  END
  1562.  
  1563. That is the _W_H_I_L_E PFO  applies  the  fewest  f's  such  that
  1564.  
  1565. _x:_f:_f:_f...:_p is true.
  1566.  
  1567.  
  1568. _4._3._1_0.  _F_e_t_c_h[_8]
  1569.  
  1570.  
  1571.      The fetch functional form allows easy access to associ-
  1572.  
  1573. ation  sequences (see function /sys/assoc in section 4.2.1.5
  1574.  
  1575. for a description of association  sequences.)   A  fetch  is
  1576.  
  1577. written  as ^c, where c is an object.  The fetch form is de-
  1578.  
  1579. fined by the functional equality:
  1580.  
  1581.      ^_c =_= IF EACH pair END | all THEN [id,#_c]|assoc|2
  1582.       ELSE #?
  1583.       END;
  1584.  
  1585. Note that the input is restricted to a  sequence  of  pairs.
  1586.  
  1587. For example,
  1588.  
  1589.            <<a 1> <b 2> <c 3>> : ^b -> 2
  1590.  
  1591.  
  1592. ____________________
  1593.  
  1594.    [8]The fetch functional form is being  deimplemented.  It
  1595. may or may not exist on your IFP interpreter.
  1596.  
  1597.  
  1598.  
  1599.  
  1600. February 9, 1987    IFP 0.5 Users Manual                  27
  1601.  
  1602.  
  1603. _4._4.  _C_o_m_m_e_n_t_s
  1604.  
  1605.  
  1606.      Comments are delimited by matching pairs of ``(*''  and
  1607.  
  1608. ``*)''.  Comments may be inserted anywhere not adjacent to a
  1609.  
  1610. token.  For example:
  1611.  
  1612. DEF foo AS bar; (* This is a comment.  DEF foo AS bar is not a comment *)
  1613.  
  1614.  
  1615. _4._5.  _S_y_n_t_a_x _S_u_m_m_a_r_y
  1616.  
  1617.  
  1618.      Below is an EBNF grammar for IFP:
  1619.  
  1620.  
  1621. ________________________________________________________________________________________
  1622. |Def ->            'DEF String 'AS' Comp ';'                                           |
  1623. |Comp ->            Simple { '|' Simple }                                              |
  1624. |Simple ->          Conditional | Constant | Construction | Each | Filter |            |
  1625. |                  Insert | Path | While | Fetch | Debug | FunVar                      |
  1626. |Conditional ->    'IF' Comp 'THEN' Comp { 'ELSIF' Comp 'THEN' Comp } 'ELSE' Comp 'END'|
  1627. |While ->          'WHILE' Comp 'DO' Comp 'end'                                        |
  1628. |Insert ->         'INSERT' Comp 'END'                                                 |
  1629. |Each ->           'EACH' Comp 'END'                                                   |
  1630. |Filter ->         'FILTER' Comp 'END'                                                 |
  1631. |Fetch ->          '^' String                                                          |
  1632. |Constant ->       '#' Object                                                          |
  1633. |Debug ->          '@' Object                                                          |
  1634. |FunVar ->         '{' Lhs ':=' Comp '}'                                               |
  1635. |Lhs ->            String | '[' [ Lhs { ',' Lhs } ] ']'                                |
  1636. |Construction ->   '[' [Comp {',' Comp}] ']'                                           |
  1637. |Path ->           ['/'] String {'/' String}                                           |
  1638. |Object ->         Bottom | Atom | '<' [Atom {','Atom}] '>'                            |
  1639. |Bottom ->         '?'                                                                 |
  1640. |Atom ->           Number | String | Boolean                                           |
  1641. _||B_o_o_l_e_a_n__-_>_________'_t_'__|__'_f_'_____________________________________________________________||
  1642.  
  1643. Strings may be in single  or  double  quotes.   The  strings
  1644. ``t''  and  ``f''  must  be  quoted to distinguish them from
  1645. boolean atoms.  Strings of digits must  also  be  quoted  to
  1646. distinguish them from numeric atoms.
  1647.  
  1648.  
  1649. _5.  _I_F_P _G_r_a_p_h_i_c_s (_o_p_t_i_o_n_a_l)[_9]
  1650. ____________________
  1651.  
  1652.    [9]This option is currently  not  implemented.   If  this
  1653. section  inspires  you,  get the source code and fix it (see
  1654. G_*.c).
  1655.  
  1656.  
  1657.  
  1658.  
  1659. February 9, 1987    IFP 0.5 Users Manual                  28
  1660.  
  1661.  
  1662.      There are no graphics primitives in IFP itself,  rather
  1663.  
  1664. IFP  is  used  to  calculate a display list.  A display-list
  1665.  
  1666. processor then draws the picture specified  by  the  display
  1667.  
  1668. list.   To  send an IFP result to the display-list processor
  1669.  
  1670. instead of the screen, use the command:
  1671.  
  1672.           graph object : function
  1673.  
  1674. instead of the ``show'' command.
  1675.  
  1676.  
  1677. _5._1.  _C_o_o_r_d_i_n_a_t_e _S_y_s_t_e_m
  1678.  
  1679.  
  1680.      Points on the graphics display are referenced by  <X,Y>
  1681.  
  1682. coordinate  pairs.  <0,0> is the lower left corner, <1,1> is
  1683.  
  1684. the upper left corner.   Currently  there  is  no  clipping.
  1685.  
  1686. Lines  outside the display are wrap around in weird and not-
  1687.  
  1688. so-wonderful ways.
  1689.  
  1690.  
  1691. _5._2.  _D_i_s_p_l_a_y _L_i_s_t _S_t_r_u_c_t_u_r_e
  1692.  
  1693.  
  1694.      Below is an EBNF grammar for the display list.
  1695.  
  1696.  
  1697. ______________________________________________________________________________
  1698. |                                                                            |
  1699. | display-list ->   < {display-list} > | polyline | color | transform | text |
  1700. | polyline ->       <'line' { < x y > } >                                    |
  1701. | color ->          <'color' color-index display-list >                      |
  1702. | text ->           <'text' atom size ['center']>                            |
  1703. | transform ->      <'trans' t-matrix display-list >                         |
  1704. | t-matrix ->       <<Txx Txy Tx0> <Tyx Tyy Ty0>>                            |
  1705. _||_____________________________________________________________________________||
  1706.  
  1707.  
  1708. _5._2._1.  _P_o_l_y_l_i_n_e
  1709.  
  1710.  
  1711.      The polyline structure specifies a sequence of  points.
  1712.  
  1713. It is of the form:
  1714.  
  1715.  
  1716.  
  1717.  
  1718. February 9, 1987    IFP 0.5 Users Manual                  29
  1719.  
  1720.  
  1721.          <line <x ,y > <x ,y > ... <x ,y >>
  1722.              1  1    2  2        n  n
  1723. where each <x ,y > is a point coordinate.   Adjacent  points
  1724.          i  i
  1725. in  the sequence are connected with line segments. For exam-
  1726.  
  1727. ple, the sequence:
  1728.  
  1729.         <line <0 0> <0 5> <1 5> <1 0> <0 0>>
  1730.  
  1731. draws a box 1 unit wide and 5 units high.
  1732.  
  1733.  
  1734. _5._2._2.  _C_o_l_o_r
  1735.  
  1736.  
  1737.      The color structure draws the display-list in the color
  1738.  
  1739. specified  by the color index (0..15).  The color applies to
  1740.  
  1741. all parts of the  subordinate  display-list  which  are  not
  1742.  
  1743. subordinate  to a color structure within.  In other words, a
  1744.  
  1745. structure is colored by its  inner-most  bounding  ``color''
  1746.  
  1747. structure.
  1748.  
  1749.  
  1750. _5._2._3.  _T_r_a_n_s_f_o_r_m
  1751.  
  1752.  
  1753.      The  transform  structure  draws  the  display-list  as
  1754.  
  1755. transformed  by  the  t-matrix.   Transforms  may be nested.
  1756.  
  1757. Transforming a display-list converts coordinates <x,y>  into
  1758.  
  1759. coordinates <x',y'> via the formula:
  1760.  
  1761.  
  1762.         | x' |     | Txx  Txy  Tx0 |  | x |
  1763.         |    |  =  |               |  | y |
  1764.         | y' |     | Tyx  Tyy  Ty0 |  |   |
  1765.                |               |  | 1 |
  1766.  
  1767. _5._2._4.  _T_e_x_t
  1768.  
  1769.  
  1770.      The text structure draws the atom with  the  lower-left
  1771.  
  1772. corner  at (0,0).  Each character is drawn in a _s_i_z_e by _s_i_z_e
  1773.  
  1774.  
  1775.  
  1776.  
  1777. February 9, 1987    IFP 0.5 Users Manual                  30
  1778.  
  1779.  
  1780. box (including spacing) The lower-left corner of the text is
  1781.  
  1782. at  <0  0>  by default.  Including the _c_e_n_t_e_r option centers
  1783.  
  1784. the text on <0 0>.
  1785.  
  1786.  
  1787.  
  1788. _6.  _D_e_b_u_g_g_i_n_g
  1789.  
  1790.  
  1791.      Currently, IFP has simple program trace  mechanism.[10]
  1792.  
  1793. To trace a function, respond to the IFP prompt with:
  1794.  
  1795.            trace on f ,f ,...f ;
  1796.                  1  2     n
  1797. where the f's are functions to be traced.  Whenever a traced
  1798.  
  1799. function  is  invoked,  its  argument  and result are shown.
  1800.  
  1801. Also, the argument and result of all  called  functions  are
  1802.  
  1803. shown.  To stop tracing functions, respond to the IFP prompt
  1804.  
  1805. with:
  1806.  
  1807.           trace off f ,f ,...f ;
  1808.                  1  2     n
  1809.  
  1810.      When tracing, the interpreter ellipses are used to  ab-
  1811.  
  1812. breviate functions.  You can set the depth at which ellipses
  1813.  
  1814. occur with the _d_e_p_t_h command:
  1815.  
  1816.               depth n
  1817.  
  1818. where n is a non-negative integer.   The  default  depth  is
  1819.  
  1820. two.
  1821.  
  1822.  
  1823.      There is also a  functional  form  for  creating  trace
  1824.  
  1825. functions.  Its form is
  1826.  
  1827.               @_m_e_s_s_a_g_e
  1828. ____________________
  1829.  
  1830.    [10]This will be replaced by a much better trace  mechan-
  1831. ism as soon as the author as time to design one.
  1832.  
  1833.  
  1834.  
  1835.  
  1836. February 9, 1987    IFP 0.5 Users Manual                  31
  1837.  
  1838.  
  1839. The function formed always returns its  argument  unchanged,
  1840.  
  1841. and  it  prints ``message: '' followed by its argument.  For
  1842.  
  1843. example,
  1844.  
  1845.          <1 3 5> : EACH @banana END
  1846.  
  1847. will print the messages:
  1848.  
  1849.              banana: 1
  1850.              banana: 3
  1851.              banana: 5
  1852.  
  1853. This tracing functional form is for debugging only, since it
  1854.  
  1855. creates  a side effect (the message!), it is not truly func-
  1856.  
  1857. tional.
  1858.  
  1859.  
  1860.  
  1861. _7.  _D_i_f_f_e_r_e_n_c_e_s _b_e_t_w_e_e_n _I_F_P _a_n_d _B_a_c_k_u_s' _F_P
  1862.  
  1863.  
  1864. _7._1.  _D_o_m_a_i_n
  1865.  
  1866.  
  1867.      Backus' FP has two types of atom, the string and  empty
  1868.  
  1869. sequence.  IFP atoms do not include the empty sequence.  IFP
  1870.  
  1871. include numbers and truth  values  as  atoms  distinct  from
  1872.  
  1873. strings.
  1874.  
  1875.  
  1876. _7._2.  _F_u_n_c_t_i_o_n_s
  1877.  
  1878.  
  1879.      There are many new  primitives.   See  the  section  on
  1880.  
  1881. ``Primitives''  elsewhere.   Of  particular interest are the
  1882.  
  1883. functions _c_a_t, _d_r_o_p_l, _t_a_k_e_l, _t_a_k_e_r, and _i_o_t_a.
  1884.  
  1885.  
  1886. _7._3.  _F_u_n_c_t_i_o_n_a_l _F_o_r_m_s
  1887.  
  1888.  
  1889.      Backus' FP defines the INSERT form for empty  sequences
  1890.  
  1891. as  returning u , the right identity element of f.  IFP does
  1892.            f
  1893.  
  1894.  
  1895.  
  1896.  
  1897. February 9, 1987    IFP 0.5 Users Manual                  32
  1898.  
  1899.  
  1900. not define INSERT for empty sequences.   If  necessary,  use
  1901.  
  1902. one of the following functions:
  1903.  
  1904.        IF null THEN u  ELSE INSERT f END END
  1905.              f
  1906.        [id,u ] | apndr | INSERT f END
  1907.         f
  1908.  
  1909.      IFP has a new functional form, FILTER, which filters  a
  1910.  
  1911. sequence according to a predicate.  It is written as:
  1912.  
  1913.             FILTER p END
  1914.  
  1915. When applied to a sequence X, it returns a  sequence  of  x
  1916.                                i
  1917. for which p is true.
  1918.  
  1919.  
  1920. _7._4.  _S_y_n_t_a_x
  1921.  
  1922.  
  1923.      The IFP syntax is designed  to  facilitate  indentation
  1924.  
  1925. and  comments.   All  functional forms bracket their parame-
  1926.  
  1927. ters, so no  parentheses  are  necessary.   The  differences
  1928.  
  1929. between Backus' FP and IFP syntax are shown below.
  1930.  
  1931.  
  1932.     ___________________________________________________
  1933.    |_B_a_c_k_u_s___________I_F_P________________________________|
  1934.    | CBA             A | B | C                        |
  1935.    | [F,G,H]         [F,G,H]                          |
  1936.    | p->f;g          IF p THEN f ELSE g END           |
  1937.    | p->f; q->g; h   IF p THEN f ELSIF q THEN g ELSE h|
  1938.    | Af              EACH f END                       |
  1939.    | /f              INSERT f END                     |
  1940.    | (while p f)     WHILE p DO f END                 |
  1941.    | (_bu f x)        [id,#x] | _f                      |
  1942.    | f               #_f                               |
  1943.    | Def f =_ x       DEF f AS x;                      |
  1944.    | U               <>                               |
  1945.    | _|               ?                                |
  1946.    |___________________________________________________|
  1947.  
  1948. Also, parentheses are neither necessary nor allowed  in  IFP
  1949.  
  1950. function definitions.
  1951.  
  1952.  
  1953.  
  1954.  
  1955. February 9, 1987    IFP 0.5 Users Manual                  33
  1956.  
  1957.  
  1958.      Finally, IFP functions are arranged in a tree structure
  1959.  
  1960. and  referenced  by  pathnames.   All pathnames are expanded
  1961.  
  1962. into absolute pathnames when read by the interpreter, so the
  1963.  
  1964. meaning  of  a  pathname  is  static.   This is an important
  1965.  
  1966. point, otherwise IFP would have significantly different (and
  1967.  
  1968. more complex) semantics than Backus' FP.
  1969.  
  1970.  
  1971. _8.  _F_u_n_c_t_i_o_n_a_l _P_r_o_g_r_a_m_m_i_n_g _T_e_c_h_n_i_q_u_e_s
  1972.  
  1973.  
  1974. _8._1.  _F_u_n_c_t_i_o_n_a_l _P_r_o_g_r_a_m_m_i_n_g _I_d_e_n_t_i_t_i_e_s
  1975.  
  1976.  
  1977.      Functional programs can be improved by  algebraic  sub-
  1978.  
  1979. stitutions.   Below  is a table of some IFP identities.  The
  1980.  
  1981. notation ``f=_g'' indicates f and g are equal  and  have  the
  1982.  
  1983. same  domain.   The  notation  ``f < g'' indicates that g is
  1984.  
  1985. equal to f over f's domain, but may  have  a  larger  domain
  1986.  
  1987. than f.
  1988.  
  1989.  
  1990.  __________________________________________________________
  1991. | EACH f END | EACH g END   =_     EACH f | g END          |
  1992. | [#c,id] | distl           =_     EACH [#c,id] END        |
  1993. | [takel,dropl] | cat        <    1                       |
  1994. | apndl | length             <    2 | length | add1       |
  1995. | apndr | length             <    1 | length | add1       |
  1996. | iota | length              <    id                      |
  1997. | reverse | length          =_     length                  |
  1998. | tl | length                <    length | sub1           |
  1999. | tlr | length               <    length | sub1           |
  2000. | apndl | reverse           =_     [2 | reverse,1] | apndr |
  2001. | apndr | reverse           =_     [2,1 | reverse] | apndl |
  2002. | reverse | reverse          <    id                      |
  2003. ||_t_r_a_n_s__|__t_r_a_n_s_______________<_____i_d________________________||
  2004.  
  2005.  
  2006.  
  2007.  
  2008. February 9, 1987    IFP 0.5 Users Manual                  34
  2009.  
  2010.  
  2011. _8._2.  _C_o_m_m_o_n _S_u_b_f_u_n_c_t_i_o_n_s
  2012.  
  2013.  
  2014.      The interpreter is not very smart about common subfunc-
  2015.  
  2016. tions, it reevaluates a function every time its encountered.
  2017.  
  2018. You can always factor out such common subfunctions by creat-
  2019.  
  2020. ing extra function constructions.  Consider the function:
  2021.  
  2022.  
  2023.             [f,a,f|g,b]
  2024.  
  2025. You can move f to outside the construction  by  forming  the
  2026.  
  2027. pair [id,f] and making the transformation:
  2028.  
  2029.  
  2030.       [f, a, f|g, b]  ->  [id,f] | [2, 1|a, 2|g, 1|b]
  2031.  
  2032. In general, create the pair [id,f].  Then replace all  lead-
  2033.  
  2034. ing  occurrences  of f in the construction by the 2 selector
  2035.  
  2036. and insert a leading 1 selector elsewhere in  the  construc-
  2037.  
  2038. tion.
  2039.  
  2040.  
  2041. _8._3.  _S_t_a_t_e _M_a_c_h_i_n_e_s
  2042.  
  2043.  
  2044.      You can simulate a state machine in IFP by defining the
  2045.  
  2046. state  transition  function D, which maps an input and state
  2047.  
  2048. into another state:
  2049.  
  2050.          [input,state] : _D -> state
  2051.  
  2052. You then run the state machine with the function
  2053.  
  2054.            apndl | reverse | INSERT _D END
  2055.  
  2056. which yields the final state when  applied  to  the  initial
  2057.  
  2058. conditions <initial-state,tape>.
  2059.  
  2060.  
  2061.  
  2062.  
  2063. February 9, 1987    IFP 0.5 Users Manual                  35
  2064.  
  2065.  
  2066. _8._4.  _T_a_i_l _R_e_c_u_r_s_i_o_n
  2067.  
  2068.  
  2069.      Regrettably, the IFP  interpreter  currently  does  not
  2070.  
  2071. recognize tail recursions as iterations.  Thus near-infinite
  2072.  
  2073. recursions will cause a stack overflow.  If this is a  prob-
  2074.  
  2075. lem,  rewrite the function with the WHILE functional form to
  2076.  
  2077. remove the tail recursion.
  2078.  
  2079.  
  2080.      For example, consider the tail recursive function:
  2081.  
  2082.        DEF f AS
  2083.         IF p THEN g
  2084.         ELSE h | f          (* tail recursion *)
  2085.         END;
  2086.  
  2087. We can rewrite is as:
  2088.  
  2089.         DEF f AS
  2090.              WHILE p|~ DO h END | g;
  2091.  
  2092.  
  2093. _9.  _I_n_s_t_a_l_l_a_t_i_o_n _N_o_t_e_s
  2094.  
  2095.  
  2096. _9._1.  _M_a_c_h_i_n_e _D_e_p_e_n_d_e_n_c_e
  2097.  
  2098.  
  2099.      The IFP interpreter is machine independent, as long  as
  2100.  
  2101. your  machine  has 32-bit two's complement integers and IEEE
  2102.  
  2103. floating point.  If not, you  should  take  a  look  at  the
  2104.  
  2105. struct.h  and F_arith.c source files.  The struct.h file de-
  2106.  
  2107. fines all the principle types and  limit  definitions  (e.g.
  2108.  
  2109. MaxInt,  MAXFLOAT).   The  F_arith.c contains the arithmetic
  2110.  
  2111. functions.  See the comments in the code for details.
  2112.  
  2113.  
  2114.  
  2115.  
  2116. February 9, 1987    IFP 0.5 Users Manual                  36
  2117.  
  2118.  
  2119. _9._2.  _C_o_m_p_i_l_i_n_g _O_p_t_i_o_n_s
  2120.  
  2121.  
  2122.      Look in the Makefile and "struct.h" for  possible  com-
  2123.  
  2124. piling  options.   Not  all  options  are  available  in all
  2125.  
  2126. releases.  Normally, the release version comes ready to com-
  2127.  
  2128. pile  on UNIX boxes.  For MSDOS, you will have to modify the
  2129.  
  2130. Makefile and change the OPSYS variable in ``struct.h''.  The
  2131.  
  2132. graphics  interface  is  extremely machine dependent, though
  2133.  
  2134. should not be difficult to modify it for other machines.
  2135.  
  2136.  
  2137.  
  2138.  
  2139. February 9, 1987    IFP 0.5 Users Manual                  37
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159. ____________________
  2160.  
  2161.  
  2162. Bac78a.
  2163.      John Backus, "Can Programming Be Liberated from the von
  2164.      Neumann  Style?   A Functional Style and Its Algebra of
  2165.      Programs," _C_A_C_M  Vol.  21,8 pp.  613-641  ACM,  (August
  2166.      1978).
  2167.  
  2168. Rob87a.
  2169.      Arch  D.  Robison,  "A  Functional  Programming  Inter-
  2170.      preter,"   _T_H_E_S_I_S,  University  of  Illinois,  (January
  2171.      1987).
  2172.  
  2173. Rob87b.
  2174.      Arch D. Robison, "Illinois  Functional  Programming:  A
  2175.      Tutorial," _B_Y_T_E Vol. 12,2 pp. 115-125 McGraw-Hill Inc.,
  2176.      (February 1987).
  2177.  
  2178. Bad83a.
  2179.      Scott Baden, "Berkeley FP  User's  Manual,  Rev.  4.1,"
  2180.      _U_N_I_X _P_r_o_g_r_a_m_m_e_r_s _M_a_n_u_a_l, (July 27,1983).
  2181.  
  2182. Dar82a.
  2183.      J. Darlington, J.V. Guttag, P. Henderson, J.H.  Morris,
  2184.      J.E.Stoy,  G.J.  Sussman,  P.C. Treleaven, D.A. Turner,
  2185.      J.H. Williams, and D.S.  Wise,  _F_u_n_c_t_i_o_n_a_l  _P_r_o_g_r_a_m_m_i_n_g
  2186.      _a_n_d   _i_t_s   _A_p_p_l_i_c_a_t_i_o_n_s,  Cambridge  University  Press
  2187.      (1982).
  2188.  
  2189. Bac81a.
  2190.      John Backus, "The Algebra of Functional Programs: Func-
  2191.      tional  Level Reasoning, Linear Equations, and Extended
  2192.      Definitions," in _F_o_r_m_a_l_i_z_a_t_i_o_n _o_f _P_r_o_g_r_a_m_m_i_n_g _C_o_n_c_e_p_t_s,
  2193.      Springer Verlag,  New York (1981).
  2194. SHAR_EOF
  2195. #    End of shell archive
  2196. exit 0
  2197.  
  2198. -- 
  2199.  
  2200. Rich $alz            "Anger is an energy"
  2201. Cronus Project, BBN Labs    rsalz@pineapple.bbn.com
  2202. Moderator, comp.sources.unix    sources@uunet.uu.net
  2203.